// import 'dart:html';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class NumberContainer extends StatelessWidget {
  final int number;
  Animation _animation;
  AnimationController _animationController;
  NumberContainer(this.number, this._animation, this._animationController);


  @override
  Widget build(BuildContext context) {
    Map<int,List<List<int>>> colormap = {};
    colormap[0] = [[1,1,1,1,1,1,1,1,1],[1,0,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,0,1],[1,0,0,0,0,0,0,0,1],[1,1,1,1,1,1,1,1,1]];
    colormap[1] = [[0,1,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];
    colormap[2] = [[1,0,0,0,1,1,1,1,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,1,1,1,1,0,0,0,1]];
    colormap[3] = [[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,1,1,1,1,1,1,1,1]];
    colormap[4] = [[1,1,1,1,1,0,0,0,0],[0,0,0,0,1,0,0,0,0],[0,0,0,0,1,0,0,0,0],[0,0,0,0,1,0,0,0,0],[1,1,1,1,1,1,1,1,1]];
    colormap[5] = [[1,1,1,1,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,1,1,1,1]];
    colormap[6] = [[1,1,1,1,1,1,1,1,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,1,1,1,1]];
    colormap[7] = [[1,0,0,0,0,0,0,0,0],[1,0,0,0,0,0,0,1,1],[1,0,0,0,0,1,1,0,0],[1,0,0,1,1,0,0,0,0],[1,1,1,0,0,0,0,0,0]];
    colormap[8] = [[1,1,1,1,1,1,1,1,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,1,1,1,1,1,1,1,1]];
    colormap[9] = [[1,1,1,1,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,0,0,0,1,0,0,0,1],[1,1,1,1,1,1,1,1,1]];
    List<Widget> widgets = [];
    void initColor(){
      widgets = [];
      colormap.forEach((key, value) {
        if (key==number){
          // print("-> $value");
          for (int i=0;i<value.length;i++){
            // print(value[i]);
            // print("第一行");
            List<Widget> shower_column = [];
            for (int n=0;n<value[i].length;n++){
              // print(value[i][n]);
              int what = value[i][n];
              if (what==0){
                // print("black");
                shower_column.add(Container(
                  width: 55,
                  height: 55,
                  color: Colors.black,
                ));
              } else {
                // print("colorful");
                shower_column.add(Container(
                  width: 55,
                  height: 55,
                  color: _animation.value,
                ));
              }
            }
            widgets.add(Column(mainAxisAlignment: MainAxisAlignment.center,children: shower_column,));
          }
        }
      });
    }
    return Container(
      child: AnimatedBuilder(
        animation: _animationController,
        builder: (context, child) {
          var r = Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: widgets,
          );
          initColor();
          return r;
        },
      ),
    );
  }
}